import { checkActor } from "../utils/mirUtil";
import { randomInRange } from "../utils/utls";
import { getSlaveManage, getSpecialMonManage } from "../系统功能/GlobalObjectManage";
import { MaxPercentNum } from "../配置/基础配置";
import { getStrengSkillPower } from "../配置/强化技能";


export class SkillManage {

    onMagicSpell(Player: TPlayObject, UserMagic: TUserMagic, nTargetX: number, nTargetY: number,
        Target: TActor, Handled: boolean): boolean {
        if (UserMagic.Name === "施毒术") {
            if (!checkActor(Target)) {
                return true;
            }
            if (Player.IsFriendlyTarget(Target)) {
                return true;
            }
            let dc = randomInRange(Player.DCMin, Player.DCMax + 1);
            let power = getStrengSkillPower(UserMagic);
            let value = Math.floor((dc / 4 + 5) * (1 + power / MaxPercentNum))

            Target.SetState(1, 120, 8)
            Target.SetState(0, 120, value)
            // Target.SetState(0, 120, 255)
            Player.Damage(Target, 1)
            getSpecialMonManage().onMonDamage(Target, Player, value * 5);


            return true;
        }

        return getSlaveManage().onMagicSpell(Player, UserMagic, nTargetX, nTargetY, Target, Handled);;
    };

    onMonitorDamageEx(ActorObject: TActor, ADamageSource: TActor,
        Tag: number, magic: TUserMagic, Value: number): number {
        let skillDamageAdd = {
            噬血术: 2.5,
            刺杀剑术: 1.2,
            灭天火: 2,
        }
        let value = Value;
        let xs = skillDamageAdd[magic.Name]
        if (xs) {
            value = value * xs
        }
        else if (magic.Name == "灵魂火符") {
            let sc = randomInRange(ADamageSource.SCMin, ADamageSource.SCMax + 1)
            let mac = randomInRange(ActorObject.MACMin, ActorObject.MACMax + 1)
            value = Math.floor(8 * magic.Level + (sc - mac) * 0.85)

        }
        return value
    }

}